 
#ifndef UTIL_H_
#define UTIL_H_

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include "debug.h"
#include <string.h>
#include <stdio.h>
#include "ExternDefOfGlobalVariables.h"

using namespace std;
class Util {
public:


	static vector<string> split(string str, string splitter) {

		vector<string> res;

		for (unsigned int i = 0; i < str.length();) {
			int pos = str.find(splitter, i);
			string split_str = str.substr(i, pos - i);
			if (split_str != "") {
				res.push_back(split_str);
			}
			i = pos + splitter.length();
			if (pos < 0) {
				break;
			}
		}

		return res;
	}

	static int string_to_int(std::string var) {
		DEBUG("string to int"<<var);
		int res = 0;
		istringstream mystream(var);
		mystream >> res;
		DEBUG("string to int,res="<<res);
		return res;
	}

	static string int_to_string(int var) {
		ostringstream mystream;
		mystream << var;
		return mystream.str();
	}

	static string char_to_string(char *var) {
		string res(var);
		return res;
	}
};
#endif /* UTIL_H_ */
